﻿using Microsoft.AspNetCore.Mvc;
using PHMEE.Admin.Controllers;
using Volo.Abp.Application.Dtos;

namespace PHMEE.Admin.HttpApi.Controllers.BaseInfo.Companies
{
    /// <summary>
    /// 公司管理🚢🌞🌛✨
    /// </summary>
    [Route("phmeeadmin/api/company")]
    public class CompanyController : PHMEEAdminController
    {
        private readonly ICompanyAppService companyAppService;
        /// <summary>
        /// 构造函数注入
        /// </summary>
        /// <param name="companyAppService"></param>
        public CompanyController(ICompanyAppService companyAppService)
        {
            this.companyAppService = companyAppService;
        }

        /// <summary>
        /// 创建公司
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("CreateCompany")]
        public async Task<Guid> CreateCompany(CompanyCreateDto input)
        {
            return await companyAppService.CreateCompanyAsync(input);
        }

        /// <summary>
        /// 更新公司
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        [Route("UpdateCompany")]
        public async Task UpdateCompany(CompanyUpdateDto input)
        {
            await companyAppService.UpdateCompanyAsync(input);
        }

        /// <summary>
        /// 公司详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetCompanyById")]
        public async Task<CompanyDto> GetCompanyById(Guid id)
        {
            return await companyAppService.GetCompanyByIdAsync(id);

        }

        /// <summary>
        /// 删除公司
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("DeleteCompany")]
        public async Task DeleteCompany(Guid id)
        {
            await companyAppService.DeleteCompanyAsync(id);

        }

        /// <summary>
        /// 公司分页集合
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetPagedCompanies")]
        public async Task<PagedResultDto<CompanyDto>> GetPagedCompanies(CompanyListDto input)
        {
            return await companyAppService.GetPagedCompaniesAsync(input);
        }

    }
}
